/*
 * Copyright 2016 Huawei Technologies Co., Ltd.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.openo.nfvo.resmanagement.service.entity;

import org.apache.commons.lang3.StringUtils;
import org.openo.nfvo.resmanagement.common.util.JsonUtil;

import net.sf.json.JSONObject;

/**
 *
 * Location entity class.<br>
 * <p>
 * </p>
 *
 * @author
 * @version     NFVO 0.5  Sep 10, 2016
 */
public class LocationEntity {

    /**
     * This field was generated by MyBatis Generator. This field corresponds to
     * the database column location.ID
     *
     * @mbggenerated
     */
    private String id;

    /**
     * This field was generated by MyBatis Generator. This field corresponds to
     * the database column location.COUNTRY
     *
     * @mbggenerated
     */
    private String country;

    /**
     * This field was generated by MyBatis Generator. This field corresponds to
     * the database column location.LOCATION
     *
     * @mbggenerated
     */
    private String location;

    /**
     * This field was generated by MyBatis Generator. This field corresponds to
     * the database column location.LATITUDE
     *
     * @mbggenerated
     */
    private String latitude;

    /**
     * This field was generated by MyBatis Generator. This field corresponds to
     * the database column location.LONGITUDE
     *
     * @mbggenerated
     */
    private String longitude;

    private String description;

    /**
     * This method was generated by MyBatis Generator. This method returns the
     * value of the database column location.ID
     *
     * @return the value of location.ID
     * @mbggenerated
     */
    public String getId() {
        return id;
    }

    /**
     * This method was generated by MyBatis Generator. This method sets the
     * value of the database column location.ID
     *
     * @param id
     *            the value for location.ID
     * @mbggenerated
     */
    public void setId(String id) {
        this.id = id == null ? null : id.trim();
    }

    /**
     * This method was generated by MyBatis Generator. This method returns the
     * value of the database column location.COUNTRY
     *
     * @return the value of location.COUNTRY
     * @mbggenerated
     */
    public String getCountry() {
        return country;
    }

    /**
     * This method was generated by MyBatis Generator. This method sets the
     * value of the database column location.COUNTRY
     *
     * @param country
     *            the value for location.COUNTRY
     * @mbggenerated
     */
    public void setCountry(String country) {
        this.country = country == null ? null : country.trim();
    }

    /**
     * This method was generated by MyBatis Generator. This method returns the
     * value of the database column location.LOCATION
     *
     * @return the value of location.LOCATION
     * @mbggenerated
     */
    public String getLocation() {
        return location;
    }

    /**
     * This method was generated by MyBatis Generator. This method sets the
     * value of the database column location.LOCATION
     *
     * @param location
     *            the value for location.LOCATION
     * @mbggenerated
     */
    public void setLocation(String location) {
        this.location = location == null ? null : location.trim();
    }

    /**
     * This method was generated by MyBatis Generator. This method returns the
     * value of the database column location.LATITUDE
     *
     * @return the value of location.LATITUDE
     * @mbggenerated
     */
    public String getLatitude() {
        return latitude;
    }

    /**
     * This method was generated by MyBatis Generator. This method sets the
     * value of the database column location.LATITUDE
     *
     * @param latitude
     *            the value for location.LATITUDE
     * @mbggenerated
     */
    public void setLatitude(String latitude) {
        this.latitude = latitude == null ? null : latitude.trim();
    }

    /**
     * This method was generated by MyBatis Generator. This method returns the
     * value of the database column location.LONGITUDE
     *
     * @return the value of location.LONGITUDE
     * @mbggenerated
     */
    public String getLongitude() {
        return longitude;
    }

    /**
     * This method was generated by MyBatis Generator. This method sets the
     * value of the database column location.LONGITUDE
     *
     * @param longitude
     *            the value for location.LONGITUDE
     * @mbggenerated
     */
    public void setLongitude(String longitude) {
        this.longitude = longitude == null ? null : longitude.trim();
    }

    /**
     * @return Returns the description.
     */
    public String getDescription() {
        return description;
    }

    /**
     * @param description The description to set.
     */
    public void setDescription(String description) {
        this.description = description == null ? null : description.trim();
    }

    /**
     *
     * To Entity.<br>
     *
     * @param jsonObject
     * @return
     * @since  NFVO 0.5
     */
    public static LocationEntity toEntity(JSONObject jsonObject) {
        LocationEntity sodoresesEntity = new LocationEntity();
        sodoresesEntity.setId(JsonUtil.getJsonFieldStr(jsonObject, "id"));
        sodoresesEntity.setCountry(JsonUtil.getJsonFieldStr(jsonObject, "country"));
        sodoresesEntity.setLocation(JsonUtil.getJsonFieldStr(jsonObject, "location"));
        sodoresesEntity.setLatitude(JsonUtil.getJsonFieldStr(jsonObject, "latitude"));
        sodoresesEntity.setLongitude(JsonUtil.getJsonFieldStr(jsonObject, "longitude"));
        sodoresesEntity.setDescription(JsonUtil.getJsonFieldStr(jsonObject, "description"));
        return sodoresesEntity;
    }

    @Override
    public String toString() {
        JSONObject locationJson = new JSONObject();
        locationJson.put("id", StringUtils.trimToEmpty(this.getId()));
        locationJson.put("country", StringUtils.trimToEmpty(this.getCountry()));
        locationJson.put("location", StringUtils.trimToEmpty(this.getLocation()));
        locationJson.put("latitude", StringUtils.trimToEmpty(this.getLatitude()));
        locationJson.put("longitude", StringUtils.trimToEmpty(this.getLongitude()));
        locationJson.put("description", StringUtils.trimToEmpty(this.getDescription()));
        return locationJson.toString();
    }
}
